home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / New System Software Extensions / ASLM SDK v1.1.2 / ASLM Examples / ExampleLibrary / Sources / ExampleClass.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-21  |  3.5 KB  |  144 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        ExampleClass.h
  3.  
  4.     Contains:    Declarations for the TExampleClass
  5.  
  6.     Copyright:    © 1991-1993 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9.  
  10.  
  11. #ifndef __EXAMPLECLASS__
  12. #define __EXAMPLECLASS__
  13.  
  14.  
  15. // the functionset ID for the example library
  16. #define kExampleFunctionSet "appl:exam$ExampleFSet,1.1"
  17.  
  18. #ifndef __LIBRARYMANAGER__
  19. #include <LibraryManager.h>
  20. #endif
  21.  
  22. #ifdef __cplusplus
  23.  
  24. #ifndef __LIBRARYMANAGERCLASSES__
  25. #include <LibraryManagerClasses.h>
  26. #endif
  27.  
  28. typedef unsigned long    ulong;
  29. typedef char*            (* MPWC HelloCPtr)(ulong*);
  30. typedef pascal Ptr        (*HelloPPtr)(ulong&);
  31. //
  32. // If we're compiling a Symantec C++ library, undefine MPWC
  33. // We define _CDECL to be _cdecl so that the destructor will be
  34. // "C" calling conventions.  Otherwise, we define _CDECL to be
  35. // whatever MPWC already is.
  36. //
  37. #if __SCLIBRARY__
  38. #undef MPWC
  39. #define MPWC
  40. #define _CDECL    _cdecl
  41. #else
  42. #define _CDECL    MPWC
  43. #endif
  44.  
  45. /**********************************************************************
  46. ** class TExampleClass
  47. ***********************************************************************/
  48.  
  49. #define kTExampleClassID    "appl:exam$TExampleClass,1.1"
  50.  
  51. #if __SCLIBRARY__
  52. class TExampleClass : public TSCDynamic
  53. #else
  54. class TExampleClass : public TDynamic
  55. #endif
  56. {
  57.     public:
  58.                                 MPWC TExampleClass();
  59.         virtual                    ~ _CDECL TExampleClass();
  60.         
  61.         // New Methods
  62.  
  63.         virtual char*             MPWC GetObjectName() const;
  64.         virtual void             MPWC SetObjectName(char *theName);
  65.  
  66.         virtual    void            MPWC DoThisAndThat();
  67.         virtual    void            MPWC DoThat();
  68.  
  69.         virtual void            MPWC SetGlobalInt(long theValue);
  70.         virtual long            MPWC GetGlobalInt();
  71.  
  72.         // Public non-virtual function
  73.         // Dynamically exported by using ExportFunction
  74.         void                    MPWC GetGlobalRef(long*&);
  75.  
  76.         // Public static function
  77.         // Dynamically exported by the ExportFunction
  78.         static Boolean            MPWC Test(ulong test);
  79.         static Boolean            MPWC Test(char* test);
  80.         
  81.     private:        
  82.         char *fName;
  83.         
  84.         // static gExampleClassCount counts the number of instances
  85.         static long                gExampleClassCount;
  86. };
  87.  
  88.  
  89. extern "C" char* HelloC(ulong*);
  90. ulong Goodbye();
  91. //
  92. // Unfortunately, Symantec C++ does not handle overloaded _cdecl functions,
  93. // even though it handles overloaded _cdecl methods, so we resort to a hack
  94. // here.  If we're compiling with Symantec - we use the mangled names of the
  95. // "C" Functions to allow the link to work.  Of course, if we compile 
  96. // ExampleClass with Symantec C++, and link it with Symantec C++ this problem
  97. // doesn't exist.
  98. //
  99. #if defined(THINK_CPLUS)
  100. pascal Ptr HELLOPASCAL(ulong& theHelloTicks);
  101. pascal ulong GOODBYEPASCAL();
  102. #else
  103. pascal Ptr HelloPascal(ulong& theHelloTicks);
  104. pascal ulong GoodbyePascal();
  105. #endif
  106.  
  107. #if defined(THINK_CPLUS) && !__SCLIBRARY__
  108.  
  109. #define kHelloRef    Hello__FRUl
  110. #define kHelloPtr    Hello__FPUl
  111.  
  112. char* MPWC Hello__FRUl(ulong&);
  113. char* MPWC Hello__FPUl(ulong*);
  114. #else
  115.  
  116. #define kHelloRef    Hello
  117. #define kHelloPtr    Hello
  118.  
  119. char* Hello(ulong&);
  120. char* Hello(ulong*);
  121. #endif
  122.  
  123. #else
  124.  
  125. typedef void TExampleClass;
  126.  
  127. /* Inline message dispatching code */
  128. #define JSRA1          0x4e91
  129. #define dispatchMessage(routineID)        \
  130.     {0x2057,0x2050,0x2268,(4*routineID),JSRA1}
  131.  
  132. void ExDestructor(TExampleClass* this) = dispatchMessage(1);
  133. char* ExGetObjectName(TExampleClass* this) = dispatchMessage(9);
  134. void ExSetObjectName(TExampleClass* this, char *theName) = dispatchMessage(10);
  135. void ExDoThisAndThat(TExampleClass* this) = dispatchMessage(11);
  136. void ExDoThat(TExampleClass* this) = dispatchMessage(12);
  137. void ExSetGlobalInt(TExampleClass* this, long theValue) = dispatchMessage(13);
  138. long ExGetGlobalInt(TExampleClass* this) = dispatchMessage(14);
  139.  
  140. char* Hello();
  141.  
  142. #endif
  143. #endif
  144.